package com.tedu.cooshark.service;

import com.tedu.cooshark.dao.CategoryMapper;
import com.tedu.cooshark.entity.Category;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 2022/3/24  14:15
 */
@Service
public class CategroyService {
    @Autowired
    private CategoryMapper categoryMapper;
    public List<Category> selectAll(){
        return categoryMapper.selectAll();
    }
    public int insert(Category category){
        return categoryMapper.insert(category);
    }
    public int deleteById(int id){
       return categoryMapper.deleteById(id);
    }
    public Category selectById(int id){
       return categoryMapper.selectById(id);
    }
    public int updateCategory(Category category){
        return categoryMapper.updateCategory(category);
    }
    public int deleteByIds(List<Category> categorys){
        int n=0;
        for (Category category : categorys) {
            categoryMapper.deleteById(category.getId());
            n++;
        }
        return n;
    }
}
